import Vue from "vue";
import VueRouter from "vue-router";
Vue.use(VueRouter);

const routes = [
    { path: "/", redirect: "/home" },
    {
        path: "/indexPage",
        name: "indexPage",
        component: () => import("../views/IndexPage.vue"),
        children: [
            {
                path: "",
                meta: "",
                component: () => import("../views/Home.vue")
            },
            {
                path: "/home",
                meta: "home",
                component: () => import("../views/Home.vue")
            },
            {
                path: "/monitor",
                name: "monitor",
                meta: "监控",
                component: () => import("../views/Monitor.vue")
            },
            {
                path: "/device",
                name: "device",
                meta: "设备",
                component: () => import("../views/Device.vue")
            }
        ]
    }
];

const router = new VueRouter({
    mode: "hash",
    base: process.env.BASE_URL,
    routes
});
//
// router.beforeEach((to, from, next) => {
//     let jmpClientToken = storageHelper.get("jmp_client_token");
//     if (jmpClientToken) {
//         next();
//     } else {
//         if (to.path === "/login" || to.path === "/forgotPassword" || to.path === "/register") {
//             next();
//         } else {
//             next("/login");
//         }
//     }
// });
export default router;
